#include <stdlib.h>
#include <assert.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#include <Judy.h>

#include "globals.h"
#include "defaults.h"
#include "limits.h"

Pvoid_t atomic_concepts; // = (Pvoid_t) NULL;
Pvoid_t atomic_roles; // = (Pvoid_t) NULL;

void init() {
	subclass_ax_count = 0;
	eqclass_ax_count = 0;

	atomic_concept_count = 0;

	// initialize hash for mapping concept names to ids
	// concept_names_ids = (PWord_t) NULL;

	// allocate place for MAX_CONCEPT_COUNT atomic concepts
	// atomic_concepts = (Concept**) malloc(MAX_CONCEPT_COUNT * sizeof(Concept*));
	// assert(atomic_concepts != NULL);

	atomic_concepts = (Pvoid_t) NULL;

	atomic_role_count = 0;

	// initialize hash for mapping role names to ids
	// role_names_ids = (PWord_t) NULL;

	// allocate place for MAX_ROLE_COUNT atomic roles
	// atomic_roles = (Role**) malloc(MAX_ROLE_COUNT * sizeof(Role*));
	// assert(atomic_roles != NULL);

	atomic_roles = (Pvoid_t) NULL;

	// TODO: make the tbox.axioms dynamic!
	tbox.axiom_count = 0;
	// tbox.axioms = (Axiom**) malloc(MAX_AXIOM_COUNT * sizeof(Axiom*));
	// assert(tbox.axioms != NULL);
	tbox.axioms = NULL;

	// initialize the normalized_tbox
	// normalized_tbox.axiom_count = 0;
	// axioms will be dynamically added
	// normalized_tbox.axioms = NULL; 

	// get the number of cores
	// TODO: platform independent!
	// core_count = sysconf(_SC_NPROCESSORS_ONLN);

	// allocate space for the thread ids
	// thread_ids = (pthread_t*) malloc(core_count * sizeof(pthread_t));

	// allocate space for the arg vectors of threads
	// (this is now done p_normalization.c)
	/*
	thread_argvs = (int **) malloc(core_count * sizeof(void*));
	int i;
	for (i = 0; i < core_count; ++i) {
		thread_argvs[i] = (int*) malloc(4 * sizeof(void*));
		// index of the axiom where the normalization should begin
		thread_argvs[i][0] = 0;
		// index of the axiom where the normalization should stop
		thread_argvs[i][1] = 0;
		// pointer to where the resulting normalized axioms should go
		thread_argvs[i][2] = (Axiom**)
			malloc(MAX_NORMALIZED_AX_PER_THREAD * sizeof(Axiom*));
	}
	*/
}

// TODO:
// void reInit() {
// }

